package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2021-12-09
 * Time: 11:46
 */
public class Book {
    private String name;  // 书名
    private String author;// 作者
    private int price;  // 价格
    private String type; // 类型
    private boolean isBorrowed; // 是否借出

    public Book(String name, String author, int price, String type) { // 构造方法
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }
// 为book类的private属性提供get和set方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    @Override
    public String toString() {     // 重写to string方法，之后打印book的时候就会按这种方式将图书的信息打印出来
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
               (isBorrowed == true ? " 已被借出" : " 未被借出")+
                '}';
    }
}
